package com.kexio.log.analytics.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 日志分析配置属性
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
@ConfigurationProperties(prefix = "kexio.log.analytics")
public class LogAnalyticsProperties {
    
    /**
     * 是否启用日志分析
     */
    private boolean enabled = false;
    
    /**
     * 日志收集间隔 (毫秒)
     */
    private long collectInterval = 30000;
    
    /**
     * 分析执行间隔 (毫秒)
     */
    private long analysisInterval = 300000;
    
    /**
     * 分析配置
     */
    private Analysis analysis = new Analysis();
    
    /**
     * 告警配置
     */
    private Alert alert = new Alert();
    
    /**
     * 报告配置
     */
    private Report report = new Report();
    
    /**
     * 数据保留配置
     */
    private Retention retention = new Retention();
    
    /**
     * 性能优化配置
     */
    private Performance performance = new Performance();
    
    public static class Analysis {
        /**
         * 启用性能分析
         */
        private boolean enablePerformance = true;
        
        /**
         * 启用错误分析
         */
        private boolean enableError = true;
        
        /**
         * 启用用户行为分析
         */
        private boolean enableUserBehavior = true;
        
        /**
         * 启用模式识别
         */
        private boolean enablePatternRecognition = false;
        
        /**
         * 启用异常检测
         */
        private boolean enableAnomalyDetection = false;
        
        // Getters and Setters
        public boolean isEnablePerformance() { return enablePerformance; }
        public void setEnablePerformance(boolean enablePerformance) { this.enablePerformance = enablePerformance; }
        
        public boolean isEnableError() { return enableError; }
        public void setEnableError(boolean enableError) { this.enableError = enableError; }
        
        public boolean isEnableUserBehavior() { return enableUserBehavior; }
        public void setEnableUserBehavior(boolean enableUserBehavior) { this.enableUserBehavior = enableUserBehavior; }
        
        public boolean isEnablePatternRecognition() { return enablePatternRecognition; }
        public void setEnablePatternRecognition(boolean enablePatternRecognition) { this.enablePatternRecognition = enablePatternRecognition; }
        
        public boolean isEnableAnomalyDetection() { return enableAnomalyDetection; }
        public void setEnableAnomalyDetection(boolean enableAnomalyDetection) { this.enableAnomalyDetection = enableAnomalyDetection; }
    }
    
    public static class Alert {
        /**
         * 错误率预警阈值 (0.0 - 1.0)
         */
        private double errorRateThreshold = 0.05;
        
        /**
         * 慢请求预警阈值 (毫秒)
         */
        private long slowRequestThreshold = 2000;
        
        /**
         * 内存泄漏检测
         */
        private boolean memoryLeakDetection = true;
        
        /**
         * 异常频率预警阈值 (每小时)
         */
        private int exceptionFrequencyThreshold = 100;
        
        /**
         * 是否启用邮件通知
         */
        private boolean emailNotification = false;
        
        /**
         * 邮件接收地址
         */
        private String emailRecipients = "";
        
        // Getters and Setters
        public double getErrorRateThreshold() { return errorRateThreshold; }
        public void setErrorRateThreshold(double errorRateThreshold) { this.errorRateThreshold = errorRateThreshold; }
        
        public long getSlowRequestThreshold() { return slowRequestThreshold; }
        public void setSlowRequestThreshold(long slowRequestThreshold) { this.slowRequestThreshold = slowRequestThreshold; }
        
        public boolean isMemoryLeakDetection() { return memoryLeakDetection; }
        public void setMemoryLeakDetection(boolean memoryLeakDetection) { this.memoryLeakDetection = memoryLeakDetection; }
        
        public int getExceptionFrequencyThreshold() { return exceptionFrequencyThreshold; }
        public void setExceptionFrequencyThreshold(int exceptionFrequencyThreshold) { this.exceptionFrequencyThreshold = exceptionFrequencyThreshold; }
        
        public boolean isEmailNotification() { return emailNotification; }
        public void setEmailNotification(boolean emailNotification) { this.emailNotification = emailNotification; }
        
        public String getEmailRecipients() { return emailRecipients; }
        public void setEmailRecipients(String emailRecipients) { this.emailRecipients = emailRecipients; }
    }
    
    public static class Report {
        /**
         * 自动生成报告
         */
        private boolean autoGenerate = true;
        
        /**
         * 每日报告
         */
        private boolean dailyReport = true;
        
        /**
         * 每周报告
         */
        private boolean weeklyReport = true;
        
        /**
         * 支持的报告格式
         */
        private String[] formats = {"json", "csv"};
        
        /**
         * 报告保留天数
         */
        private int retentionDays = 30;
        
        /**
         * 自动清理过期报告
         */
        private boolean autoCleanup = true;
        
        /**
         * 报告存储路径
         */
        private String storagePath = "/tmp/log-reports";
        
        // Getters and Setters
        public boolean isAutoGenerate() { return autoGenerate; }
        public void setAutoGenerate(boolean autoGenerate) { this.autoGenerate = autoGenerate; }
        
        public boolean isDailyReport() { return dailyReport; }
        public void setDailyReport(boolean dailyReport) { this.dailyReport = dailyReport; }
        
        public boolean isWeeklyReport() { return weeklyReport; }
        public void setWeeklyReport(boolean weeklyReport) { this.weeklyReport = weeklyReport; }
        
        public String[] getFormats() { return formats; }
        public void setFormats(String[] formats) { this.formats = formats; }
        
        public int getRetentionDays() { return retentionDays; }
        public void setRetentionDays(int retentionDays) { this.retentionDays = retentionDays; }
        
        public boolean isAutoCleanup() { return autoCleanup; }
        public void setAutoCleanup(boolean autoCleanup) { this.autoCleanup = autoCleanup; }
        
        public String getStoragePath() { return storagePath; }
        public void setStoragePath(String storagePath) { this.storagePath = storagePath; }
    }
    
    public static class Retention {
        /**
         * 原始日志保留时间 (天)
         */
        private int rawLogsDays = 7;
        
        /**
         * 聚合数据保留时间 (天)
         */
        private int aggregatedDataDays = 30;
        
        /**
         * 报告保留时间 (天)
         */
        private int reportsDays = 90;
        
        // Getters and Setters
        public int getRawLogsDays() { return rawLogsDays; }
        public void setRawLogsDays(int rawLogsDays) { this.rawLogsDays = rawLogsDays; }
        
        public int getAggregatedDataDays() { return aggregatedDataDays; }
        public void setAggregatedDataDays(int aggregatedDataDays) { this.aggregatedDataDays = aggregatedDataDays; }
        
        public int getReportsDays() { return reportsDays; }
        public void setReportsDays(int reportsDays) { this.reportsDays = reportsDays; }
    }
    
    public static class Performance {
        /**
         * 异步处理
         */
        private boolean asyncProcessing = true;
        
        /**
         * 批处理大小
         */
        private int batchSize = 1000;
        
        /**
         * 线程池大小
         */
        private int threadPoolSize = 4;
        
        /**
         * 缓冲区大小
         */
        private int bufferSize = 10000;
        
        // Getters and Setters
        public boolean isAsyncProcessing() { return asyncProcessing; }
        public void setAsyncProcessing(boolean asyncProcessing) { this.asyncProcessing = asyncProcessing; }
        
        public int getBatchSize() { return batchSize; }
        public void setBatchSize(int batchSize) { this.batchSize = batchSize; }
        
        public int getThreadPoolSize() { return threadPoolSize; }
        public void setThreadPoolSize(int threadPoolSize) { this.threadPoolSize = threadPoolSize; }
        
        public int getBufferSize() { return bufferSize; }
        public void setBufferSize(int bufferSize) { this.bufferSize = bufferSize; }
    }
    
    // Getters and Setters
    public boolean isEnabled() { return enabled; }
    public void setEnabled(boolean enabled) { this.enabled = enabled; }
    
    public long getCollectInterval() { return collectInterval; }
    public void setCollectInterval(long collectInterval) { this.collectInterval = collectInterval; }
    
    public long getAnalysisInterval() { return analysisInterval; }
    public void setAnalysisInterval(long analysisInterval) { this.analysisInterval = analysisInterval; }
    
    public Analysis getAnalysis() { return analysis; }
    public void setAnalysis(Analysis analysis) { this.analysis = analysis; }
    
    public Alert getAlert() { return alert; }
    public void setAlert(Alert alert) { this.alert = alert; }
    
    public Report getReport() { return report; }
    public void setReport(Report report) { this.report = report; }
    
    public Retention getRetention() { return retention; }
    public void setRetention(Retention retention) { this.retention = retention; }
    
    public Performance getPerformance() { return performance; }
    public void setPerformance(Performance performance) { this.performance = performance; }
}
